﻿using Utility.Global;
using Utility.Persistence_Service;

namespace Application_Core.Kunde_Component.Data_Access_Layer
{
    public class Adresse : EntityComponent
    {
        public virtual string Strasse { get; set; }

        public virtual string Hausnummer { get; set; }

        public virtual int PLZ { get; set; }

        public virtual string Ort { get; set; }

        public Adresse() { }

        public Adresse(string strasse, string hausnummer, int plz, string ort)
        {
            this.Strasse = strasse;
            this.Hausnummer = hausnummer;
            this.PLZ = plz;
            this.Ort = ort;
        }

        public virtual AdresseDTO ToDTO()
        {
            AdresseDTO adresse = new AdresseDTO();
            adresse.Strasse = this.Strasse;
            adresse.Hausnummer = this.Hausnummer;
            adresse.PLZ = this.PLZ;
            adresse.Ort = this.Ort;
            return adresse;
        }

        public override bool Equals(System.Object obj)
        {
            if (obj == null)
            {
                return false;
            }

            if (GetType() != obj.GetType())
            {
                return false;
            }

            Adresse adresse = (Adresse)obj;

            return (Strasse.Equals(adresse.Strasse)) && (Hausnummer.Equals(adresse.Hausnummer)) &&
                (PLZ.Equals(adresse.PLZ)) && (Ort.Equals(adresse.Ort));
        }

        public override int GetHashCode()
        {
            int prime = 31;
            int result = 1;
            result = prime * result + Strasse.GetHashCode();
            result = prime * result + Hausnummer.GetHashCode();
            result = prime * result + PLZ.GetHashCode();
            result = prime * result + Ort.GetHashCode();
            return result;
        }
    }
}
